package quick.api.app.util;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quick.api.app.BlogApplication;

public class FormatObjectExt {

    private static Logger logger = LoggerFactory.getLogger(FormatObjectExt.class);

    public static void format(JSONObject jsonObject) {

        if (jsonObject != null && jsonObject.containsKey("ext")) {

            Object extObject = jsonObject.get("ext");
            if(extObject != null && extObject instanceof String) {
                try{
                    jsonObject.put("ext", JSON.parse((String)extObject));
                }catch (Exception e){
                    logger.error("转化ext异常, {}", e.toString());
                }
            }
        }
    }
}
